package com.missilike.core.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;

/**
 * @Author: starmile
 * @Description:
 * @Create: 2018-12-15 0:24
 **/
public class OrderUtils {
    /**
     * 获得唯一订单号
     */
    public static String getUniqueOrder() {
        return "mz" + getUniqueStr();
    }

    /**
     * 获取唯一提现订单号
     * @return
     */
    public static String getUniqueCashWithdrawalOrder() {
        return "mz" + getUniqueStr() + "tx";
    }

    /**
     * 获取唯一字符串
     * @return
     */
    private static String getUniqueStr(){
        SimpleDateFormat format = new SimpleDateFormat("YYYYMMddHHmmss");
        String format2 = format.format(new Date());
        int hashCodeV = UUID.randomUUID().toString().hashCode();
        if (hashCodeV < 0) {
            //有可能是负数
            hashCodeV = -hashCodeV;
        }
        return format2 + String.format("%012d", hashCodeV);
    }
}
